/**
 * 选项卡效果
 * author: damu
 * version: 1.0
 */
(function () {
  // 声明变量
  var _tabContainer = $(".tab-container")
  var _tabTitle = $('.tab-container .title')
  var _tabContent = $('.tab-container .item')

  // 开发特效
  function tabs(titles, contents) {
    for (var i = 0; i < titles.length; i++) {
      titles[i].index = i
      titles[i].onclick = function () {
        for (var j = 0; j < titles.length; j++) {
          titles[j].className = ""
        }
        this.className = "active"

        for (var m = 0; m < contents.length; m++) {
          contents[m].className = ""
        }
        contents[this.index].className = "active"
      }
    }
  }

  // 选项卡效果
  tabs(_tabTitle, _tabContent)
}());